{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加菜单</h5>
                </div>
                <div class="ibox-content">
                    <form id="form" class="form-horizontal" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">上级菜单：</label>
                            <div class="col-sm-4">
                                <select name="pid" class="form-control">
                                    <option value="0">--默认顶级--</option>
                                    {notempty name="ruleList"}
                                    {volist name="ruleList" id="vo"}
                                    <option value="{$vo.id}" {if condition='$li.pid == $vo.id' }selected="selected"{/if}>{$vo.lefthtml}{$vo.title}</option>
                                    {/volist}
                                    {/notempty}
                                </select>
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">菜单名称：</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" name="title" value="{$li.title ?? ''}">
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">节点：</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" name="name" value="{$li.name ?? ''}" placeholder="模块/控制器/方法">
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图标：</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" name="icon" value="{$li.icon ?? ''}">
                                <span class="help-block m-b-none"> <a href="http://fontawesome.dashgame.com/" target="_black">选择图标</a> 如:fa fa-user</span>
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类型：</label>
                            <div class="radio-box col-sm-4">
                                <div class="radio pull-left">
                                    <input type="radio" name="type" id="type_1" value="1" {if condition='$li.type == 1'}checked="checked"{/if}>
                                    <label for="type_1">菜单+节点</label>
                                </div>
                                <div class="radio pull-left ml-20">
                                    <input class="radio pull-left ml-20" type="radio" name="type" id="type_0" value="0" {if condition='$li.type == 0'}checked="checked"{/if}>
                                    <label for="type_0">只作为节点</label>
                                </div>
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="radio-box col-sm-4">
                                <div class="radio pull-left">
                                    <input type="radio" name="status" id="radio1" value="1" {if condition='$li.status == 1'}checked="checked"{/if}>
                                    <label for="radio1">启用</label>
                                </div>
                                <div class="radio pull-left ml-20">
                                    <input class="radio pull-left ml-20" type="radio" name="status" id="radio2" value="0" {if condition='$li.status == 0'}checked="checked"{/if}>
                                    <label for="radio2">禁用</label>
                                </div>
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" name="sort" value="{$li.sort ?? ''}">
                            </div>
                            <div class="input-check col-sm-4"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>
                                <a class="btn btn-danger ml-15" href="javascript:history.go(-1);"><i class="fa fa-reply"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(function () {
        $("#form").validate({
            errorElement: 'span',
            errorPlacement: function(error, element) {
                error.appendTo(getMsgBox(element));
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit(function(data){
                    if (data.code == 1) {
                        layer.msg(data.msg, {icon: 6, time: 1000}, function (index) {
                            window.location.href = "{:\\think\\Url::build('index')}";
                        });
                    } else {
                        layer.msg(data.msg, {icon: 5, time: 1200});
                    }
                    return false;
                });
            }
        });
    });
</script>
</body>
</html>